package com.dhcc.DRGsHosp.facade.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Named;

import org.springframework.beans.factory.annotation.Autowired;

import com.dhcc.DRGsHosp.application.MrQualityAnalysisApplication;
import com.dhcc.DRGsHosp.facade.DrgsIndexCalFacade;
import com.dhcc.DRGsHosp.facade.MrQualityAnalysisFacade;
import com.dhcc.DRGsHosp.facade.dto.IndexCalDTO;
import com.dhcc.DRGsHosp.facade.impl.assembler.IndexCalAssembler;
import com.dhcc.DRGsHosp.infra.util.DrgsIndex;

@Named("drgsHospFacadeImplMzy170421")
public class MrQualityAnalysisFacadeImpl implements MrQualityAnalysisFacade {
	
	@Autowired
	private MrQualityAnalysisApplication mrQualityAnalysisApplication;
	@Autowired
	private DrgsIndexCalFacade drgsIndexCalFacade;
	
	List<String> diagList = null;//获取诊断   
	List<String> operList = null;//获取手术
	
	/**  
	 *  @Description：获取已分组的病例质量数据
	 *  @Author mazhaoyan  
	 *  @see com.dhcc.DRGsHosp.facade.MrQualityAnalysisFacade#getGroupCaseQuality(java.lang.String, java.lang.String)  
	 */
	@Override
	public List<Map<String, Object>> getGroupCaseQuality(IndexCalDTO dto) {
		dto.setDateFrom(DrgsIndex.formateDateFrom(dto.getDateFrom()));
	    dto.setDateTo(DrgsIndex.formateDateTo(dto.getDateTo()));
	    String dateFrom = dto.getDateFrom();
		String  dateTo = dto.getDateTo();
		String stdId = drgsIndexCalFacade.getStdID(dateFrom,dateTo);
		String  verRegion=drgsIndexCalFacade.getGroupScheme();
		dto.setStdId(stdId);
		dto.setVerRegion(verRegion);
		return mrQualityAnalysisApplication.getGroupCaseQuality(IndexCalAssembler.toEntity(dto));
	}
	/**  
	 *  @Description：病组的详细数据
	 *  @Author mazhaoyan  
	 *  @see com.dhcc.DRGsHosp.facade.MrQualityAnalysisFacade#getGroupDetail(java.lang.String, java.lang.String, java.lang.String)  
	 */
	@Override
	public Map<String, Object> getGroupDetail(IndexCalDTO dto) {
		Map<String, Object> result = new HashMap<String, Object>();
		dto.setDateFrom(DrgsIndex.formateDateFrom(dto.getDateFrom()));
	    dto.setDateTo(DrgsIndex.formateDateTo(dto.getDateTo()));
	    String dateFrom = dto.getDateFrom();
		String  dateTo = dto.getDateTo();
		String stdId = drgsIndexCalFacade.getStdID(dateFrom,dateTo);
		String  verRegion=drgsIndexCalFacade.getGroupScheme();
		dto.setStdId(stdId);
		dto.setVerRegion(verRegion);
		dto.setType1("");
		List<Map<String, Object>> caseList = mrQualityAnalysisApplication.getGroupDetail(IndexCalAssembler.toEntity(dto));
		dto.setType1("G");
		List<Map<String, Object>> groupList = mrQualityAnalysisApplication.getGroupDetail(IndexCalAssembler.toEntity(dto));
		result.put("caseList",caseList);
		result.put("groupList",groupList);
		for(int i=0;i<6;i++)
		{//科室分布情况 0-全部 1-常规 2-一般离散(低) 3-一般离散(高) 4-高离散(低) 5-高离散(高)
			dto.setType1(i+"");
			result.put(i+"",mrQualityAnalysisApplication.getGroupDetail(IndexCalAssembler.toEntity(dto)));
		}
		return result;
	}
}
